package com.example.demo2.config;

import com.example.demo2.util.RabbitMqUtils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectRabbitMqConfigation {
    //创建交换机 路由模式
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(RabbitMqUtils.DIRECT_EXCHANGE,true,false);
    }
    //创建队列
    @Bean
    public Queue weixin_direct(){
        return new Queue("weixin_direct",true);
    }
    @Bean
    public Queue email_direct(){
        return new Queue("email_direct",true);
    }
    @Bean
    public Queue qq_direct(){
        return new Queue("qq_direct",true);
    }
    //队列绑定交换机
    @Bean
    public Binding binding11(){
        return BindingBuilder.bind(weixin_direct()).to(directExchange()).with("direct_weixin");
    }
    @Bean
    public Binding binding12(){
        return BindingBuilder.bind(email_direct()).to(directExchange()).with("direct_email");
    }
    @Bean
    public Binding binding22(){
        return BindingBuilder.bind(qq_direct()).to(directExchange()).with("direct_qq");
    }
}
